<?php
///////////////////////////////////////////////////////////////////////
//Nazov suboru:	adm_contents_random_products.php
//Popis:		Zobrazenie zoznamu tovarov pre vyber do nahodne
//				zobrazovanych tovaroch
//Poznamka:		
//
//Vsetky prava vyhradene
//////////////////////////////////////////////////////////////////////


    define('ABSOLUTE_SERVER_REMOTE_ADDR','http://'.$_SERVER['HTTP_HOST'].'/');
    define('ABSOLUTE_SERVER_DOCUMENT_ROOT','../admin/');

    include(ABSOLUTE_SERVER_DOCUMENT_ROOT.'session.inc');
    require_once(ABSOLUTE_SERVER_DOCUMENT_ROOT.'funct.inc');   
    
    require_once(ABSOLUTE_SERVER_DOCUMENT_ROOT.'functs.inc');
    include ABSOLUTE_SERVER_DOCUMENT_ROOT.'color_style.php';

    require_once('../classDB.inc.php');
    require_once('../plugins/input/classInput.inc.php');
    require_once('../plugins/session/classSession.inc.php');
    require_once('../definitions.inc.php');
    require_once('../plugins/filesystem/classFileSystem.inc.php');
    require_once('../plugins/template/classTemplate.inc.php');
    require_once('../plugins/template/classTemplate.inc.php');
    require_once('../plugins/i18n/classI18N.inc.php');
    include LANGUAGE;

    if(!GetAdminID($ID)){echo LOGIN_ERR; exit;}
    if(!Right_Check(5)){header('Location:'.ABSOLUTE_SERVER_DOCUMENT_ROOT.'error.php'); exit;}
?>
<html>

<head>
	<?php echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET_.';">'; ?>

	<style  type="text/css"><!--
		table{
            border-bottom-color: black;
            border-top-color: black;
            border-left-color: black;
            border-right-color: black;
            border-collapse: collapse;
            font-size: 10px;
            font-family:  verdana;
        }
        form {margin-top:0pt; margin-bottom:0px;}
        img {margin-top:0pt; margin-bottom:0px;}
        body{
            margin-left:10px;
            margin-right:0pt;
            margin-top:0pt;
            margin-bottom:0pt;
            font-family:  verdana;
            font-size: 10px;
        }
        input {
            border: 1px solid black;
            cursor: pointer;
            background-color: white;
            font-size: 10px;
            margin-left: 0px;
            padding-left: 0px;
            list-style-type: none;
            font-family:  Verdana;
        }
        a {
		  	text-decoration: none; 
		  	font-weight: normal; 
		  	color:black; 
		  	font-size:10px;
		}
		a:hover {
		  	text-decoration: underline; 
			font-weight: normal; 
			color:#808080; 
			font-size:10px;
		}
    --></style>
	
</head>

<?php
	print "<body bgcolor=\"".BACKGROUND_IN_TABLE."\">";

	$_DB = new classDB();
        if (!$_DB->open()){echo OPEN_DB_ERR; break;}
	
do{  
	//-----------------------------------------------------------------------------------------------
	//NADPIS
	print "<center><h4 style=\"margin-top:0pt; margin-bottom:0pt;\">".SO_NASTAVENIE_ESHOPU."</h4></center>";
	//-----------------------------------------------------------------------------------------------

    
    function getLocalizedFilesForm(){
        $_FS = new classFileSystem();
        $_I18N = new classI18N();
        $SelectedOption = $_I18N->getActual('../');
        $FileList = $_FS->getFilesList('../'._I18N_DIR_.'/','php');

        array_multisort($FileList,SORT_STRING);
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetShopLocalization" id="SetShopLocalization" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_VYBERTE_LOKALIZACIU.':
                        </td>
                        <td>
                            <select
                                name="ShopLocalizationValue"
                                id="ShopLocalizationValue"
                            >
        ';
        foreach ($FileList as $value) {
            if(basename($value,'.inc.php')==basename($SelectedOption,'.inc.php'))
                $result .= '
                    <option selected value="'.basename($value,'.inc.php').'">'.basename($value,'.inc.php').'</option>
                ';
            else
                $result .= '
                    <option value="'.basename($value,'.inc.php').'">'.basename($value,'.inc.php').'</option>
                ';
        }        
        $result .= '
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setLocalization($ID){
        $_I18N = new classI18N();
        return $_I18N->setActual($ID, '../');
    }

    function getTemplatesForm(){
        $_FS = new classFileSystem();
        $_Template = new classTemplate();
        $SelectedOption = $_Template->getActual('../');
        $DirList = $_FS->getDirsList('../'._TEMPLATE_DIR_.'/');

        array_multisort($DirList,SORT_STRING);
        $result = '          
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetShopTemplate" id="SetShopTemplate" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_VYBERTE_SABLONU.':
                        </td>
                        <td>
                            <select
                                name="ShopTemplateValue"
                                id="ShopTemplateValue"
                            >
        ';
        foreach ($DirList as $value) {
            if('../'._TEMPLATE_DIR_.'/'.$value==$SelectedOption)
                $result .= '
                    <option selected value="'.$value.'">'.$value.'</option>
                ';
            else
                $result .= '
                    <option value="'.$value.'">'.$value.'</option>
                ';
        }        
        $result .= '
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setTemplate($ID){
        $_Template = new classTemplate();
        return $_Template->setActual($ID, '../');
    }

    function getPageDescriptionForm(){
        $sfContent = '';
        if(file_exists('../data/configfiles/meta.inc')) $sfContent=file_get_contents('../data/configfiles/meta.inc');
        return '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetShopDescription" id="SetShopDescription" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_OPIS_ESHOPU.'<br />
                            <small>'.SO_1_3_KRATKE_VETY.'</small>
                        </td>
                        <td>
                            <textarea name="ShopDescriptionValue" style="width: 200px; height: 150px;">'.$sfContent.'</textarea>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
    }

    function setPageDescription($sText){
        return file_put_contents('../data/configfiles/meta.inc', $sText);
    }

    function getPageNameForm(){
        $sfContent = '';
        if(file_exists('../data/configfiles/title.inc')) $sfContent=file_get_contents('../data/configfiles/title.inc');
        return '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetShopName" id="SetShopName" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_NAZOV_ESHOPU.': 
                        </td>
                        <td>
                            <input type="text" name="ShopNameValue" id="ShopNameValue" value="'.$sfContent.'" />
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
    }

    function setPageName($sText){
        return file_put_contents('../data/configfiles/title.inc', $sText);
    }

    function getTVATForm(){
        $sfContent = '';
        $selected_yes = '';
        $selected_no = '';
        if(file_exists('../data/configfiles/vat.inc')) $sfContent=file_get_contents('../data/configfiles/vat.inc');
        if($sfContent=='YES') $selected_yes = 'selected';
        else $selected_no = 'selected';
        $result = '          
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetVAT" id="SetVAT" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_PLATCA_DPH.':
                        </td>
                        <td>
                            <select name="VATValue" id="VATValue" >
                                <option '.$selected_yes.' value="YES">'.SO_ANO.'</option>
                                <option '.$selected_no.' value="NO">'.SO_NIE.'</option>
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setVAT($sText){
        return file_put_contents('../data/configfiles/vat.inc', $sText);
    }

    function getUserOrderingForm(){
        $sfContent = '';
        $selected_yes = '';
        $selected_no = '';
        if(file_exists('../data/configfiles/userordering.inc')) $sfContent=file_get_contents('../data/configfiles/userordering.inc');
        if($sfContent=='YES') $selected_yes = 'selected';
        else $selected_no = 'selected';
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetUserOrdering" id="SetUserOrdering" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_UMOZNIT_UZIVATELSKE_ZORADOVANIE_PRODUKTOV.':
                        </td>
                        <td>
                            <select name="UserOrderingValue" id="UserOrderingValue" >
                                <option '.$selected_yes.' value="YES">'.SO_ANO.'</option>
                                <option '.$selected_no.' value="NO">'.SO_NIE.'</option>
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setUserOrdering($sText){
        return file_put_contents('../data/configfiles/userordering.inc', $sText);
    }

    function getSendOrderWithoutRegistringForm(){
        $sfContent = '';
        $selected_yes = '';
        $selected_no = '';
        if(file_exists('../data/configfiles/order.inc')) $sfContent=file_get_contents('../data/configfiles/order.inc');
        if($sfContent=='YES') $selected_yes = 'selected';
        else $selected_no = 'selected';
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetOrderWithoutRegistring" id="SetOrderWithoutRegistring" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_UMOZNIT_ODOSIELANIE_OBJEDNAVKY_BEZ_POTREBY_REGISTRACIE.':
                        </td>
                        <td>
                            <select name="OrderWithoutRegistringValue" id="OrderWithoutRegistringValue" >
                                <option '.$selected_yes.' value="YES">'.SO_ANO.'</option>
                                <option '.$selected_no.' value="NO">'.SO_NIE.'</option>
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setOrderWithoutRegistring($sText){
        return file_put_contents('../data/configfiles/order.inc', $sText);
    }

    function FirstPageForm(){

        $selected = '';
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetFirstPage" id="SetFirstPage" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.FP_NA_UVODNEJ_STRANKE.':
                        </td>
                        <td>
                            <select name="FirstPageValue" id="FirstPageValue" >
        ';
                                $sql_psel= "SELECT page FROM first_page";
                                $first_page_sql = mysql_fetch_object(mysql_query($sql_psel));
                                $first_page=$first_page_sql->page;

                                if($first_page==1) $actions_selected   = 'selected'; else	$actions_selected  = '';
                                if($first_page==2) $news_selected      = 'selected'; else	$news_selected     = '';
                                if($first_page==3) $saleout_selected   = 'selected'; else	$saleout_selected  = '';

                                $result .= '
                                    <option '.$actions_selected.'   value="1">'.FP_AKCIE.'</option>
                                    <option '.$news_selected.'      value="2">'.FP_NOVINKY.'</option>
                                    <option '.$saleout_selected.'   value="3">'.FP_VYPREDAJ.'</option>
                                ';
        $result .= '
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setFirstPage($FirstPageValue){
        if(is_numeric($FirstPageValue)){
            $sql="DELETE FROM first_page";
            mysql_query($sql);
            $sql="INSERT INTO first_page (page) VALUES ($FirstPageValue)";
            mysql_query($sql);
        }
    }

    function getInputToSetCountToBasketForm(){
        $sfContent = '';
        $selected_yes = '';
        $selected_no = '';
        if(file_exists('../data/configfiles/inpuunit.inc')) $sfContent=file_get_contents('../data/configfiles/inpuunit.inc');
        if($sfContent=='YES') $selected_yes = 'selected';
        else $selected_no = 'selected';
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetInputToSetCountToBasket" id="SetInputToSetCountToBasket" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_ZOBRAZIT_POLE_MNOZSTVO_DO_KOSIKA.':
                        </td>
                        <td>
                            <select name="InputToSetCountToBasketValue" id="InputToSetCountToBasketValue" >
                                <option '.$selected_yes.' value="YES">'.SO_ANO.'</option>
                                <option '.$selected_no.' value="NO">'.SO_NIE.'</option>
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setInputToSetCountToBasket($sText){
        return file_put_contents('../data/configfiles/inpuunit.inc', $sText);
    }

    function getProductCodeForm(){
        $sfContent = '';
        $selected_yes = '';
        $selected_no = '';
        if(file_exists('../data/configfiles/productcode.inc')) $sfContent=file_get_contents('../data/configfiles/productcode.inc');
        if($sfContent=='YES') $selected_yes = 'selected';
        else $selected_no = 'selected';
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetProductCode" id="SetProductCode" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_ZOBRAZOVAT_KOD_PRODUKTU.':
                        </td>
                        <td>
                            <select name="ProductCodeValue" id="ProductCodeValue" >
                                <option '.$selected_yes.' value="YES">'.SO_ANO.'</option>
                                <option '.$selected_no.' value="NO">'.SO_NIE.'</option>
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setProductCode($sText){
        return file_put_contents('../data/configfiles/productcode.inc', $sText);
    }

    function getFastSearchForm(){
        $sfContent = '';
        $selected_yes = '';
        $selected_no = '';
        if(file_exists('../data/configfiles/fastsearch.inc')) $sfContent=file_get_contents('../data/configfiles/fastsearch.inc');
        if($sfContent=='YES') $selected_yes = 'selected';
        else $selected_no = 'selected';
        $result = '
            <form action="adm_site_options.php" target="place" method="post">
                <input type="hidden" name="SetFastSearch" id="SetFastSearch" value="YES">
                <table>
                    <tr>
                        <td style="width:150px;">
                            '.SO_ZOBRAZOVAT_RYCHLE_HLADANIE.':
                        </td>
                        <td>
                            <select name="FastSearchValue" id="FastSearchValue" >
                                <option '.$selected_yes.' value="YES">'.SO_ANO.'</option>
                                <option '.$selected_no.' value="NO">'.SO_NIE.'</option>
                            </select>
                        </td>
                        <td>
                            <input type="submit" value="'.SO_NASTAVIT.'">
                        </td>
                    </tr>
                </table>
            </form>
        ';
        return $result;
    }

    function setFastSearch($sText){
        return file_put_contents('../data/configfiles/fastsearch.inc', $sText);
    }

    
    //-----------------------------------------------------------------------------------------------
    $SetShopLocalization    = $_REQUEST['SetShopLocalization'];
    $ShopLocalizationValue  = $_REQUEST['ShopLocalizationValue'];
	$SetShopTemplate        = $_REQUEST['SetShopTemplate'];
    $ShopTemplateValue      = $_REQUEST['ShopTemplateValue'];
    $SetShopDescription     = $_REQUEST['SetShopDescription'];
    $ShopDescriptionValue   = $_REQUEST['ShopDescriptionValue'];
    $SetShopName            = $_REQUEST['SetShopName'];
    $ShopNameValue          = $_REQUEST['ShopNameValue'];
    $SetVAT                 = $_REQUEST['SetVAT'];
    $VATValue               = $_REQUEST['VATValue'];
    $SetUserOrdering        = $_REQUEST['SetUserOrdering'];
    $UserOrderingValue      = $_REQUEST['UserOrderingValue'];
    $SetFirstPage           = $_REQUEST['SetFirstPage'];
    $FirstPageValue         = $_REQUEST['FirstPageValue'];
    $SetInputToSetCountToBasket     = $_REQUEST['SetInputToSetCountToBasket'];
    $InputToSetCountToBasketValue   = $_REQUEST['InputToSetCountToBasketValue'];
    $SetOrderWithoutRegistring      = $_REQUEST['SetOrderWithoutRegistring'];
    $OrderWithoutRegistringValue    = $_REQUEST['OrderWithoutRegistringValue'];
    $SetProductCode                 = $_REQUEST['SetProductCode'];
    $ProductCodeValue               = $_REQUEST['ProductCodeValue'];
    $SetFastSearch                  = $_REQUEST['SetFastSearch'];
    $FastSearchValue                = $_REQUEST['FastSearchValue'];

    $sMessage = '';

    if($SetFastSearch=='YES'){
        setFastSearch($FastSearchValue);
        $sMessage = SO_RYCHLE_VYHLADAVANIE_JE_NASTAVENE;
    }
    if($SetShopTemplate=='YES'){
        setTemplate($ShopTemplateValue);
        $sMessage = SO_SABLONA_JE_NASTAVENA;
    }
    if($SetShopLocalization=='YES'){
        setLocalization($ShopLocalizationValue);
        $sMessage = SO_LOKALIZACIA_JE_NASTAVENA;
    }
    if($SetVAT=='YES'){
        setVAT($VATValue);
        $sMessage = SO_PLATBA_DPH_NASTAVENA;
    }
    if($SetUserOrdering=='YES'){
        setUserOrdering($UserOrderingValue);
        $sMessage = SO_ZORADOVANIE_PRODUKTOV_NASTAVENE;
    }
    if($SetShopDescription=='YES'){
        setPageDescription($ShopDescriptionValue);
        $sMessage = SO_OPIS_JE_NASTAVENY;
    }
    if($SetShopName=='YES'){
        setPageName($ShopNameValue);
        $sMessage = SO_NAZOV_JE_NASTAVENY;
    }
    if($SetFirstPage=='YES'){
        setFirstPage($FirstPageValue);
        $sMessage = SO_UVODNA_STRANKA_JE_NASTAVENA;
    }
    if($SetInputToSetCountToBasket=='YES'){
        setInputToSetCountToBasket($InputToSetCountToBasketValue);
        $sMessage = SO_VSTUPNE_POLE_NASTAVENE;
    }
    if($SetOrderWithoutRegistring=='YES'){
        setOrderWithoutRegistring($OrderWithoutRegistringValue);
        $sMessage = SO_ODOSIELANIE_OBJEDNAVKY_BEZ_REGISTRACIE_NASTAVENE;
    }
    if($SetProductCode=='YES'){
        setProductCode($ProductCodeValue);
        $sMessage = SO_ZOBRAZOVANIE_KODU_PRODUKTU_NASTAVENE;
    }

    print '<center><font style="background:yellow;"><b>'.$sMessage.'</b></font></center><br /><br />';
    
    print getTemplatesForm(); print '<br />';
    print getLocalizedFilesForm(); print '<br />';
    print getTVATForm();     print '<br />';
    print getInputToSetCountToBasketForm(); print '<br />';
    print getUserOrderingForm(); print '<br />';
    print getProductCodeForm(); print '<br />';
    print getSendOrderWithoutRegistringForm(); print '<br />';
    print getFastSearchForm(); print '<br />';
    print getPageNameForm(); print '<br />';
    print getPageDescriptionForm(); print '<br />';
    print FirstPageForm(); print '<br />';
}
while(false);
mysql_close();
?>
</body>
</html>